package com.baizhi.utils.apache.collections;

import org.apache.commons.collections4.CollectionUtils;
import org.junit.Test;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class CollectionsUtilsTest {

    /**
     * 判断是否为空
     */
    @Test
    public void test1() {
        List<String> list = new ArrayList<>();
        System.out.println(CollectionUtils.isEmpty(list));
        System.out.println(CollectionUtils.isNotEmpty(list));
    }

    @Test
    public void test2() {
        List<String> listA = Arrays.asList("a", "b", "c");
        List<String> listB = Arrays.asList("c", "1", "2");
        // 取交集
        System.out.println(CollectionUtils.intersection(listA, listB));
        // 取并集
        System.out.println(CollectionUtils.union(listA, listB));
        // 取差集
        System.out.println(CollectionUtils.subtract(listA, listB));
    }
}
